<template>
  <el-dialog :title="title" v-model="open" append-to-body>
    <el-form
      label-position="right"
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      :label-width="100 + 'px'"
    >
      <el-form-item
        style="width: 100%"
        label="驳回理由"
        prop="refuseReason"
        :rules="[
          {
            required: true,
            message: '请输入驳回理由',
            trigger: ['blur'],
          },
        ]"
      >
        <!-- <el-input
          type="textarea"
          v-model="queryParams.refuseReason"
          placeholder="请输入"
          clearable
        /> -->
        <el-select
          style="width: 80%"
          v-model="queryParams.refuseReason"
          :multiple="false"
          placeholder="请选择"
          clearable
        >
          <el-option
            v-for="dict in refuseReasonList"
            :key="dict.value"
            :label="dict['dictLabel']"
            :value="dict['dictLabel']"
          />
        </el-select>
      </el-form-item>
      <div style="text-align: right">
        <el-button type="primary" size="mini" @click="handleQuery"
          >确认</el-button
        >
        <el-button size="mini" @click="open = false">取消</el-button>
      </div>
    </el-form>
  </el-dialog>
</template>
<script setup>
import request from '@/utils/request'
const props = defineProps({
  url: {
    type: String,
    default: '',
  },
  id: {
    type: String,
    default: '',
  },
});
let title = ref("驳回理由");
let open = ref(false);
let queryParams = ref({});
const emit = defineEmits(['updateData']);
const { proxy } = getCurrentInstance();
const show = () => {
  open.value = true;
};
const handleQuery = () => {
  proxy.$refs.queryForm.validate((valid) => {
    if (valid) {
      request({
      url: props.url,
      method: 'post',
      params: {
        id: props.id,
        refuseReason: queryParams.value.refuseReason,
      }
    }).then((res) => {
      emit("updateData", true);
      if (res.status == 0) {
        proxy.$modal.msgSuccess('驳回成功')
      } else {
        proxy.$modal.msgError(res.msg)
      }
      
       open.value = false;
    })
    }
  })
};
defineExpose({
  show,
});
const refuseReasonList = ref([])
const refuseReasonListFun = () => {
  // refuseReasonList
  request({
    url: '/system/dict/data/type/refuse_reason_list',
    method: 'get',
  }).then((res) => {
    refuseReasonList.value = res.data
  })
}
refuseReasonListFun()
</script>